from django.db import models


class QUser(models.Model):
    username = models.CharField(max_length=32)
    password = models.CharField(max_length=32)
    email = models.EmailField()
    has_store = models.IntegerField(default=0)


class QUserInfo(models.Model):
    nickname = models.CharField(max_length=32)
    phone = models.CharField(max_length=32)
    address = models.CharField(max_length=32)
    age = models.IntegerField()
    gender = models.CharField(max_length=32)
    usi_us = models.OneToOneField(to=QUser, on_delete=models.CASCADE)


class Address(models.Model):
    acc_name = models.CharField(max_length=32)
    acc_addr = models.TextField()
    acc_post = models.CharField(max_length=32)
    acc_phone = models.CharField(max_length=32)
    is_default = models.IntegerField(default=0)
    add_QuUer = models.ForeignKey(to=QUser, on_delete=models.CASCADE)


from store.models import Goods


class Cart(models.Model):
    c_user = models.ForeignKey(to=QUser, on_delete=models.CASCADE, default=1)
    c_goods = models.ForeignKey(to=Goods, on_delete=models.CASCADE, default=1)
    c_count = models.IntegerField()


class Order(models.Model):
    o_goods = models.ManyToManyField(to=Goods)
    o_user = models.ForeignKey(to=QUser, on_delete=models.CASCADE)
    order_number = models.CharField(max_length=32)
    all_money = models.FloatField(default=0.00)
    pay_method = models.CharField(max_length=32, default='支付宝')
    address = models.CharField(max_length=32, default='北京市')
    is_trade = models.IntegerField(default=0)


class Glance(models.Model):
    glance_number = models.IntegerField()
